package org.xukai.rest.ws;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.socket.TextMessage;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @author xukai
 * @desc
 * @date 2017-11-01-18:05
 */
@Controller
public class GarlicPriceController {
    @Resource
    PfWebSocketHandler myWebSocketHandler;
    @RequestMapping(value = "GarlicPriceController/testWebSocket", method ={RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=utf-8")
    @ResponseBody
    public String testWebSocket() throws IOException {
        myWebSocketHandler.broadcast(new TextMessage("\"number\":\""+"GarlicPriceController/testWebSocket"+"\""));
        return "1";
    }

}